var CountScene=CountScene||{};
CountScene.CountScene=function(){
	var s = this;
	F2xContainer.call(s);
	s.initUI();
	s.RootMC.GuideMC.stop();
    s.musicBtn.open.visible=false;
    s.musicBtn.close.visible=false;
	s.arrowBtn.visible=false;
	s.initTime=0;//秒数
	s.initStep=0;
	s.setStep(s.initStep);
	s.setTime(s.initTime);
	s.runTime();
    s.RootMC.addEventListener(annie.MouseEvent.MOUSE_DOWN,function () {
        s.runTime();
    })
    s.RootMC.addEventListener(annie.MouseEvent.MOUSE_UP,function () {
        s.stopTime();
    })
	var isClose=false;
	//音乐按钮
    s.musicBtn.addEventListener(annie.MouseEvent.CLICK,function (){
    	if(BgIndex==1){
            if(BgOne.media.paused){
                BgOne.pause(false);
			}else{
                BgOne.pause();
			}
		}else{
            if(BgTwo.media.paused){
                BgTwo.pause(false);
            }else{
                BgTwo.pause();
            }
		}
        if(!isClose){
        	trace("关闭音乐");
            s.musicBtn.close.visible=true;
            s.musicBtn.open.visible=false;
            isClose=true;
		}else{
        	trace("打开音乐");
            s.musicBtn.close.visible=false;
            s.musicBtn.open.visible=true;
            isClose=false;
		}
    })
};
F2xExtend(CountScene.CountScene,F2xContainer);
CountScene.CountScene.prototype.setTime=function (t) {
	var s = this;
	var hours = Math.floor((t/3600%24));
	var min = Math.floor(t/60%60);
	var second = Math.floor(t%60);
	// trace(hours+"时"+min+"分"+second+"秒");
	//秒
	var s0MC=s.RootMC.s0MC;
	var s1MC=s.RootMC.s1MC;
    s0MC.gotoAndStop(Math.floor(second%10)+1);
    s1MC.gotoAndStop(Math.floor(second/10)+1);

    //分
	var m0MC=s.RootMC.m0MC;
    var m1MC=s.RootMC.m1MC;
    m0MC.gotoAndStop(Math.floor(min%10)+1);
    m1MC.gotoAndStop(Math.floor((min/10)%10)+1);

    //时
	var h0MC=s.RootMC.h0MC;
	var h1MC=s.RootMC.h1MC;
    h0MC.gotoAndStop(Math.floor(hours%10)+1);
    h1MC.gotoAndStop(Math.floor((hours/10)%10)+1);
};
//设置步数
CountScene.CountScene.prototype.setStep=function(step){
    var s = this;
    /*步伐*/
    var step1 = s.RootMC.step1MC;
    var step2 = s.RootMC.step2MC;
    var step3 = s.RootMC.step3MC;
    var step4 = s.RootMC.step4MC;
    step1.gotoAndStop(Math.floor(step%10)+1);
    step2.gotoAndStop(Math.floor((step/10)%10)+1);
    step3.gotoAndStop(Math.floor((step/100)%10)+1);
    step4.gotoAndStop(Math.floor((step/1000)%10)+1);
}
//启动步数,时间
CountScene.CountScene.prototype.runTime=function (type) {
	var s= this;
	type?type:"";//判断在哪个场景
    s.RootMC.addEventListener(annie.Event.ENTER_FRAME,function () {
		if(type!=1){
            s.initTime+=3;
            s.initStep++;
            s.setStep(s.initStep);
            s.setTime(s.initTime);
            s.RootMC.GuideMC.play();
		}else{
            s.initTime++;
            s.initStep++;
            s.setStep(s.initStep);
            s.setTime(s.initTime);
            s.RootMC.GuideMC.play();
		}
    })
}
//停止步数时间
CountScene.CountScene.prototype.stopTime=function () {
	var s= this;
    s.RootMC.removeAllEventListener();
    s.RootMC.GuideMC.stop();
}
//重置时间,步数
CountScene.CountScene.prototype.resetTime=function(){
	var s = this;
    s.initTime=0;//秒数
    s.initStep=0;
    s.setStep(s.initStep);
    s.setTime(s.initTime);
    s.RootMC.GuideMC.stop();
}
CountScene.CountScene.prototype.initUI=function(){
	var s = this;
	//f2x_auto_created_init_start
	var _d0=new CountScene.F2xAuto_16();
	_d0.name="arrowBtn";
	s.arrowBtn=_d0;
	Flash2x.d(_d0,{x:320.6,y:921.2});
	var _d1=new CountScene.F2xAuto_19();
	_d1.name="musicBtn";
	s.musicBtn=_d1;
	Flash2x.d(_d1,{x:56.15,y:124.2,a:1.96,b:1.96});
	var _d3=new CountScene.ewwer();
	_d3.name="RootMC";
	s.RootMC=_d3;
	var _d2=new CountScene.F2xAuto_15();
	s.addChild(_d2);
	s.addChild(_d3);
	s.addChild(_d1);
	s.addChild(_d0);
	//f2x_auto_created_init_end
	
};
